Chris Pollett >
Old Classses > |
HW#4 --- last modified February 07 2019 04:37:47..Due date: Nov 18
Files to be submitted: Purpose:To make your own REST web service, to gain experience working with XML, JSON. Related Course Outcomes: The main course outcomes covered by this assignment are: LO2 -- Write schemas, DTDs, and style sheets for XML documents. LO4 -- Write client-side scripts that validate HTML forms. LO5 -- Develop and deploy web applications that involve components, web services, and databases. Specification: For this homework you will create a REST-based advertising web service as well as a minimal site to test your web service is working. Within the Hw4.zip file you submit, there should be two subfolders BestSiteAd and SiteTest corresponding to these two sites. Both of these web apps should be developed using the frameworks and folder structures we have used in Hw2 and Hw3. PHP allows for a very crude form of url rewriting that does not require any special web server configuration. Namely, if you have a url of the form: http://somewhere.com/some-path/index.php/method_name/?arg1=value1&...&arg_n=value_n Then the script index.php will be executed by the web server, as a substring of $_SERVER["REQUEST_URI"] you can determine the method_name, and $_REQUEST will contain the arguments of the query string. Using this set-up, you could determine a controller and a particular activity for that controller from method name and then be back to the framework used in Hw2 and Hw3. You should use this strategy to implement BestSiteAd. The idea of BestSiteAd is you are an advertising company and you are trying to determine which is the best ad for a given fixed product (for example, you might have three or four possible campaigns to promote a laundry detergent and you want to try to figure out which is the best). It should support the following three methods:
In addition to this REST service, the BestSiteAd should have a landing page that displays the current number of clicks for each ad choice. This page should have a link "Reset Counters" which when clicked resets all the ad choice counters to 0. Finally, the landing page should have a functional form to add a new advertisement and also a link beside each currently listed ad that would cause that add to be deleted. The BestSiteAd folder should also have a sub-folder xml. This should have a file ad.dtd which should describe your xml ad language used in get-ad. XML advertisements output by get-ad should validate against this dtd. You can check this using Oxygen XML Editor (1 month trial license is free). The SiteTest web page should be just a page that displays ten news stories that you make up. Each time you refresh the stories should be displayed in a different order. Stories should be displayed in div tags. After the first displayed news item, there should be a blank div with id advertisement. Using a Javascript onload event in the body of your page, you should request the get-ad method of the BestSiteAd service and display an ad with a slightly different background color than the rest of the news items. To do this I want you to make use of a proxy script on SiteTest that proxies the information from BestSiteAd. Whether xml or json is used for the request should be configurable from your configs/config.php file for SiteTest. All links on the SiteTest page should go back to the SiteTest page itself. So a link for a news item first goes to the SiteTest page which then redirects to the real URL of that item. Similarly, for ads. Before the redirect occurs, it should call the increment-choice method of the news item or ad in question. Let's assume all news items have Ad id 0 and actual ads have positive Ad ids. Point Breakdown
|